package cc.telecomdigital.tdstock.trading.Common;


import cc.telecomdigital.tdstock.R;
import android.content.Context;

public class Trade_SymbolTranslation
{
	public static final String	TRANSACTIONTYPE_BID		= "B";
	public static final String	TRANSACTIONTYPE_ASK		= "A";

	public static final String	TRANSSTATUS_PROCESSING	= "1";
	public static final String	TRANSSTATUS_DONE		= "2";
	public static final String	TRANSSTATUS_REJECTED	= "3";
	public static final String	TRANSSTATUS_CANCELED	= "4";
	public static final String	TRANSSTATUS_RECEIVED	= "5";
	public static final String	TRANSSTATUS_TRANSFERING	= "6";
	public static final String	TRANSSTATUS_QUEUEING	= "7";
	public static final String	TRANSSTATUS_ASKING		= "8";
	public static final String	TRANSSTATUS_ASKING2		= "32";
	public static final String	TRANSSTATUS_NEW_PORT	= "9";
	public static final String	TRANSSTATUS_NEW_PORT2	= "40";

	/** Translated B or A into reading string **/
	public static String TranslateTransType(Context iContext, String iSymbol)
	{
		if (iSymbol.equals(TRANSACTIONTYPE_BID))
			return iContext.getResources().getString(R.string.stockBuyText);

		if (iSymbol.equals(TRANSACTIONTYPE_ASK))
			return iContext.getResources().getString(R.string.stockSellText);

		return iContext.getResources().getString(R.string.UnknownText);
	}

	/** Translated B or A into reading string(abbreviated, english) **/	
	public static String TranslateTransTypeAbrev(Context iContext,
			String iSymbol)
	{
		if (iSymbol.equals(TRANSACTIONTYPE_BID))
			return iContext.getResources().getString(
					R.string.stockBuyText_abrev);

		if (iSymbol.equals(TRANSACTIONTYPE_ASK))
			return iContext.getResources().getString(
					R.string.stockSellText_abrev);

		return iContext.getResources().getString(R.string.UnknownText);
	}

	/** Checking whether the status of order allowed to edit; from GetOrderMultiple **/
	public static boolean IsStockOrderEditable(String iStatusCode)
	{
		if (iStatusCode == null)
			return false;

		if (iStatusCode.equals(TRANSSTATUS_RECEIVED)
				|| iStatusCode.equals(TRANSSTATUS_TRANSFERING)
				|| iStatusCode.equals(TRANSSTATUS_QUEUEING)
				|| iStatusCode.equals(TRANSSTATUS_NEW_PORT)
				|| iStatusCode.equals(TRANSSTATUS_NEW_PORT2)
				|| iStatusCode.equals(TRANSSTATUS_ASKING)
				|| iStatusCode.equals(TRANSSTATUS_ASKING2)
				|| iStatusCode.equals(TRANSSTATUS_PROCESSING))
			return true;

		return false;
	}
}